#pragma once

namespace bs
{
	class FpsController
	{
	public:
		FpsController();
		~FpsController();

		size_t GetCurTime() { return this->curTime; }
		size_t GetCurFrame() { return this->curFrame; }
		size_t GetElapseTime() { return this->curTime-this->lastTime; }
		int GetCurFps() { return this->curFps; }

		void SetDestFps(int fps);
		size_t Process();     // return curTime
		bool Start();
		void Stop();
		void Pause();
		void Resume();

		bool IsRunning() { return this->state==RUNNING; }
		bool IsPaused() { return this->state==PAUSED; }
		bool IsStoped() { return this->state==STOPED; }

	private:
		size_t curTime;
		size_t lastTime;
		size_t startTime;
		size_t timeCntBegin;

		size_t curFrame;
		size_t frameCntBegin;

		int curFps;
		int destFps;

		HANDLE timer;

		enum 
		{ 
			RUNNING, 
			PAUSED,
			STOPED
		} state;
	};

}